package com.lonwin.inspectionmanagement.mvp.model;

import android.app.Application;

import com.google.gson.Gson;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;

import com.jess.arms.di.scope.ActivityScope;

import javax.inject.Inject;

import com.lonwin.inspectionmanagement.mvp.contract.HomeContract;
import com.lonwin.inspectionmanagement.mvp.contract.HomeContract.Model;
import com.lonwin.inspectionmanagement.mvp.model.api.service.BusinessService;
import com.lonwin.inspectionmanagement.mvp.model.entity.bean.HhkqLhAliasBean;
import com.lonwin.inspectionmanagement.mvp.model.entity.bean.QueryNumBean;

import java.util.Map;

import io.reactivex.Observable;
import io.reactivex.functions.Function;


@ActivityScope
public class HomeModel extends BaseModel implements Model {
    @Inject
    Gson mGson;
    @Inject
    Application mApplication;

    @Inject
    public HomeModel(IRepositoryManager repositoryManager) {
        super(repositoryManager);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.mGson = null;
        this.mApplication = null;
    }

    @Override
    public Observable<HhkqLhAliasBean> queryHhkqLhAlias(String url, Map<String,String> maps) {
        return mRepositoryManager.obtainRetrofitService(BusinessService.class).queryHhkqLhAlias(url,maps)
                .map(new Function<HhkqLhAliasBean, HhkqLhAliasBean>() {
                    @Override
                    public HhkqLhAliasBean apply(HhkqLhAliasBean hhkqLhAliasBean) throws Exception {
                        return hhkqLhAliasBean;
                    }
                });
    }

    @Override
    public Observable<QueryNumBean> getHzUnCheckXcjlbCount(String url, Map<String, Object> params) {
        return mRepositoryManager.obtainRetrofitService(BusinessService.class).getHzUnCheckXcjlbCount(url,params);
    }
}